/*
**************************************************************************************************************
File:         testbench_hvl.sv
Description:  Testbench (HVL) for TBX mode
Author     :  Aditya Joshi, Rohit Kulkarni
**************************************************************************************************************
*/

import xtlm_pkg::*; // For trans-language TLM channels.

import params::*;

//File Handlers
`define INPUTFILENAME "input_command.txt"		// filename for test data
parameter debug=0;

class stimulus_gen ;

	xtlm_fifo #(bit[(packet_size_in_bytes*8)-1:0]) driverChannel;
	int m,r;
	int data_file, eof, scan_file_command, scan_file_address;  
	
	reg command;
	reg [LOGICAL_ADDR_WIDTH-1:0] address;
	
	function new();			//Constructor 
		begin
			driverChannel = new ("top.inputpipe");									
		  data_file = $fopen(`INPUTFILE
NAME, "r");
eof = $feof(data_file);
		end
	endfunction

	task run;

 		 	  
 		 
     while(!eof)
     begin
       scan_file_command = $fscanf(data_file, "%b", command);
		   scan_file_address = $fscanf(data_file,"%h\n", address);		 
eof = $feof(data_file);

    		 driverChannel.put({command,address});      
		 	end
		 		
     	driverChannel.flush_pipe;		
      $fclose(data_file);               
	endtask

	endclass


module testbench_hvl;
	
	 stimulus_gen stim_gen;
	     		
		initial
		begin 	
		stim_gen = new ();
      stim_gen.run();
		end



endmodule
